package com.zp.config;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;

/**
 * @author zp
 * @description
 * @created 2021/12/1 16:07
 */

public class MyBeanDefinitionRegistry implements BeanDefinitionRegistryPostProcessor {
    private BeanDefinitionRegistry beanDefinitionRegistry;
    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
        this.beanDefinitionRegistry = registry;
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        beanFactory.registerScope("myRefresh",new RefreshScope());
    }

    public BeanDefinitionRegistry getBeanDefinitionRegistry(){
        return this.beanDefinitionRegistry;
    }
}
